package com.inscream.app;

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TabHost;

import com.inscream.app.profileTab.EditMyProfile;
import com.inscream.app.profileTab.MyFavorites;


public class TabTab  extends TabActivity {
    /** Called when the activity is first created. */
    RelativeLayout myScream, myFavorites, editMyProfile;
    TabHost tabHost;
    public static String Tab="";
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_tab_tab);
        tabHost = getTabHost();
        myScream=(RelativeLayout)findViewById(R.id.myScream);
        myFavorites=(RelativeLayout)findViewById(R.id.myFavorites);
        editMyProfile=(RelativeLayout)findViewById(R.id.editMyProfile);

        // Tab for tab1
        TabHost.TabSpec spec1 = tabHost.newTabSpec("Tab1");
        // setting Title and Icon for the Tab
        spec1.setIndicator("Tab1");
        Intent Intent1 = new Intent(this, ProfileActivity.class);
        spec1.setContent(Intent1);

        // Tab for tab2
        TabHost.TabSpec spec2 = tabHost.newTabSpec("Tab2");
        // setting Title and Icon for the Tab
        spec2.setIndicator("Tab2");
        Intent Intent2 = new Intent(this, MyFavorites.class);
        spec2.setContent(Intent2);

        // Tab for tab2
        TabHost.TabSpec spec3 = tabHost.newTabSpec("Tab3");
        // setting Title and Icon for the Tab
        spec3.setIndicator("Tab3");
        Intent Intent3 = new Intent(this, EditMyProfile.class);
        spec3.setContent(Intent3);

        // Adding all TabSpec to TabHost
        tabHost.addTab(spec1); // Adding tab1
        tabHost.addTab(spec2); // Adding tab2
        tabHost.addTab(spec3); // Adding tab3
    }

    public void tabHandler(View target) {
        if (target.getId() == R.id.myScream) {
            Tab="this is Tab myScream";
            tabHost.setCurrentTab(0);

        } else if (target.getId() == R.id.myFavorites) {
            Tab="this is myFavorites";
            tabHost.setCurrentTab(1);

        } else if (target.getId() == R.id.editMyProfile) {
            Tab="this is editMyProfile";
            tabHost.setCurrentTab(2);

        }
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.tab_tab, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }

}
